package com.scy.hospitalmanager.service.person.provider.impl;

import com.baomidou.mybatisplus.core.incrementer.DefaultIdentifierGenerator;
import com.baomidou.mybatisplus.core.incrementer.IdentifierGenerator;
import com.scy.hospitalmanager.dao.person.provider.PersonBasicInfoPDao;
import com.scy.hospitalmanager.pojo.entity.PersonBasicInfoPDO;
import com.scy.hospitalmanager.service.person.provider.PersonBasicInfoPService;
import com.scy.hospitalmanager.until.CertUtils;
import com.scy.hospitalmanager.until.NameUtils;
import org.springframework.stereotype.Service;

import javax.annotation.Resource;

/**
 * @author ZuoWei Jin, 13504284153
 * @version 1.0
 * @description 人员基本信息生产者服务
 * @since 2021/10/1 19:20
 */
@Service
public class PersonBasicInfoPServiceImpl implements PersonBasicInfoPService {

    @Resource
    PersonBasicInfoPDao personBasicInfoPDao;

    @Override
    public void allInsertPerson() {
        int count = 10;
        while (count>0){
            IdentifierGenerator id = new DefaultIdentifierGenerator();
            PersonBasicInfoPDO pdo = new PersonBasicInfoPDO();
            System.out.println(id);
            pdo.setPsnBasId((Long) id.nextId(pdo));
            pdo.setCreator(NameUtils.generateName());
            pdo.setCerNo(CertUtils.createRandomID());
            pdo.setPsnNo(pdo.getCerNo().substring(1,5));
            pdo.setCerType("1");
            pdo.setGender(CertUtils.getGenderByIdCard(pdo.getCerNo()));
            pdo.setBirth(CertUtils.getBirthByIdCard(pdo.getCerNo()));
            pdo.setHouRegistration(CertUtils.getProvinceByIdCard(pdo.getCerNo()));
            personBasicInfoPDao.insert(pdo);
            System.out.println(pdo);
            count--;
        }

    }
}
